package site.marqstree.kotlin.usercenter.ui.activity.login

import site.marqstree.kotlin.library.base.presenter.view.BasePresenter
import site.marqstree.kotlin.library.base.data.net.observer.RxObserver
import site.marqstree.kotlin.library.base.data.net.request.RxRequest
import site.marqstree.kotlin.library.base.extent.json2Bean
import site.marqstree.kotlin.provider.common.ProviderConstant
import site.marqstree.kotlin.usercenter.data.bean.LoginBean
import javax.inject.Inject

/*
 * 项目名: KotlinMall
 * 包名: site.marqstree.kotlin.usercenter.presenter
 * 文件名: LoginPresenter
 * 创建者: marqstree
 * 创建时间: 2020/2/22 13:24
 * 描述: TODO
 */
/*
    登录界面 Presenter
 */
class LoginPresenter @Inject constructor() : BasePresenter<LoginView>() {

    /*
        登录
     */
    fun login(mobile: String, pwd: String) {

        RxRequest.builder()
            .setUrl(ProviderConstant.SIGN_IN_URL)
            .setParam("mobile",mobile)
            .setParam("password",pwd)
            .post()
            .json2Bean(LoginBean::class.java)
            .subscribe(object :RxObserver<LoginBean>(){
                override fun onNext(data: LoginBean) {
                    mView.onLoginResult(data.convert2UserInfo())
                }
            })
    }

}
 